package com.gxa.service.asset.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.asset.MaintenancePlan;
import com.gxa.entity.asset.MaintenanceTicket;
import com.gxa.entity.asset.search.MaintenPlanSearchMap;
import com.gxa.entity.asset.search.MaintenTicketSearchMap;
import com.gxa.service.asset.MaintenanceTicketService;
import com.gxa.mapper.asset.MaintenanceTicketMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【t_maintenance_ticket(运维工单表)】的数据库操作Service实现
* @createDate 2022-10-13 11:16:24
*/
@Service
public class MaintenanceTicketServiceImpl extends ServiceImpl<MaintenanceTicketMapper, MaintenanceTicket>
    implements MaintenanceTicketService{

    @Autowired
    private MaintenanceTicketMapper maintenanceTicketMapper;

    @Override
    public PageInfo<MaintenanceTicket> queryByPage(MaintenTicketSearchMap map) {

        PageHelper.startPage(map.getPageNum(),map.getPageSize());//1.开启分页

        QueryWrapper<MaintenanceTicket> wrapper = new QueryWrapper<>();//2.条件构造器 模拟写动态sql  或者在xml 中写
        if (!StringUtils.isBlank(map.getUintName())) {
            wrapper.like("ticket_name", map.getUintName());
        }
        if(!StringUtils.isBlank(map.getExePerson())){
            wrapper.like("person",map.getExePerson());
        }
        if(!StringUtils.isBlank(map.getStatus())){
            wrapper.eq("maintenance_ticket_state",map.getStatus());
        }

        if(!StringUtils.isAnyBlank(map.getStartTime(),map.getEndTime())){
            wrapper.between("submission_time",map.getStartTime(),map.getEndTime());
        }
        PageInfo<MaintenanceTicket> pageInfo = new PageInfo<>(maintenanceTicketMapper.selectList(wrapper));//3.获取分页信息
        return pageInfo;
    }
}




